package com;

import java.util.Calendar;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class JavaTest {
    public static void main(String[] args) {
        System.out.println(Pattern.compile("^\\d{4}-$").matcher("12").matches());
        Calendar instance = Calendar.getInstance();
        Calendar instance1 = Calendar.getInstance();
        instance.setTime(new Date());
        System.out.println(instance.get(Calendar.MONTH) + instance.get(Calendar.YEAR) * 12);
        System.out.println(1+1<0+1);

        String str = "12a56a55=66";
        System.out.println(JavaTest.isDigit(str));
        while (JavaTest.isDigit(str)){
            System.out.println(JavaTest.getNumbers(str));
            str = str.replaceFirst("\\d+", "--");
        }
        System.out.println(str);
    }
    //截取数字
    public static String getNumbers(String content) {
        Pattern pattern = Pattern.compile("\\d+");
        Matcher matcher = pattern.matcher(content);
        while (matcher.find()) {
            return matcher.group(0);
        }
        return "";
    }
    // 判断一个字符串是否都为数字
    public static boolean isDigit(String strNum) {
        return strNum.matches(".*\\d+.*");
    }
}
